package com.example.demo.controller;

import com.example.demo.config.PropertiesPathConfig;
import com.example.demo.util.PropertiesUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.Properties;

@RestController
@RequestMapping("/properties")
public class PropertiesController {
    @Autowired
    private PropertiesPathConfig propertiesPathConfig;

    @GetMapping("/load")
    public Map load() {
        return PropertiesUtil.read(propertiesPathConfig.getReadFilePath());
    }

    @GetMapping("store")
    public void store() {
        PropertiesUtil.write(propertiesPathConfig.getWriteFilePath());
    }
}
